//
//  LXSignTableViewCell.m
//  ZuLinProject
//
//  Created by bancheng on 2022/1/6.
//  Copyright © 2022 LX_App. All rights reserved.
//

#import "LXSignTableViewCell.h"
#import "LXSignContractModel.h"

@implementation LXSignTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.backgroundColor = [UIColor colorWithHexString:@"#FAFBFC"];
    [self.backView addCorner:4];
    [self.label8 customizedCornerTopLeft:0 topRight:04 bottomLeft:4 bottomRight:0];
    [self.fromLabl addCorner:2];
}

- (void)setSignModel:(LXSignContractModel *)signModel{
    _signModel = signModel;
    
    
    self.fromLabl.textColor =  mainColor;
    self.fromLabl.backgroundColor = [mainColor colorWithAlphaComponent:0.1];

    if (signModel.fromType == 2) {
        self.fromLabl.hidden = NO;
        self.label1LeftCons.constant = 35;
        
    }
    else {
        self.fromLabl.hidden = YES;
        self.label1LeftCons.constant = 15;
    }
    
    
    // 车牌
    self.label1.textColor = [UIColor colorWithHexString:@"#222222"];
    self.label1.text = [NSString stringWithNull:signModel.carNum];
    // 车型
    self.label2.textColor = [UIColor colorWithHexString:@"#333333"];
    self.label2.text = [NSString stringWithFormat:@"%@ %@",signModel.carBrand,signModel.carModel];
    
    
    // 交租提醒
    if (signModel.rentRemindFlag == 1) {
        self.label3.textColor = [UIColor colorWithHexString:@"#FF921C"];
    }
    else {
        self.label3.textColor = ColorWithAAAAAA;
    }
    self.label4.textColor = Color333;
    if (signModel.signType==1 || signModel.signType == 3) {
        // 租金
        NSString *rentStr = signModel.rent;
        self.label4.text = [NSString stringWithFormat:@"%@元/月",rentStr];
        [self.label4 addAttributes:TextAttrCorlor([UIColor colorWithHexString:@"#FF921C"]) forText:rentStr size:[UIFont systemFontOfSize:20 weight:UIFontWeightMedium]];
        
        
        self.label3.text = [NSString stringWithFormat:@"每月%@日交租",signModel.payDate];
        
        
    }
    else if (signModel.signType==2) {
        
        // 首付金额
        NSString *firstPayStr = signModel.firstPay;
        self.label4.text = [NSString stringWithFormat:@"%@万元起",firstPayStr];
        [self.label4 addAttributes:TextAttrCorlor([UIColor colorWithHexString:@"#FF921C"]) forString:firstPayStr];
        [self.label4 addAttributes:TextAttrCorlor([UIColor colorWithHexString:@"#FF921C"]) forText:firstPayStr size:[UIFont systemFontOfSize:20 weight:UIFontWeightMedium]];


        self.label3.text = [NSString stringWithFormat:@"每月%@日分期",signModel.payDate];
    }
    self.label6.textColor = Color333;
    self.label6.text = [NSString stringWithFormat:@"%@",signModel.driverName];
    
    
    
    [self.label8 setTitle:signModel.endTime forState:UIControlStateNormal];
    [self.label8 setTitleColor:[UIColor colorWithHexString:@"#FF921C"] forState:UIControlStateNormal];

    if (signModel.reNewFlag == 1 && signModel.signStatus != 3) {
        [self.label8 setTitleColor:[UIColor colorWithHexString:@"#FF921C"] forState:UIControlStateNormal];
        [self.label8 setImage:Image(@"warning_icon") forState:UIControlStateNormal];
        [self.label8 setIconInRightWithSpacing:2];
    }
    else {
        [self.label8 setTitleColor:ColorWith333333 forState:UIControlStateNormal];
        [self.label8 setImage:Image(@"") forState:UIControlStateNormal];
        [self.label8 setIconInLeftWithSpacing:0];
    }
    
    self.label13.text = [NSString stringWithFormat:@"利行联系人：%@",!StringIsEmpty(signModel.businessName)?signModel.businessName:@"无"];
    
    self.label11.textColor = [UIColor colorWithHexString:@"#FF921C"];
    if (!StringIsEmpty(signModel.appointmentId)) {
        self.label11.hidden = NO;
    }
    else {
        self.label11.hidden = YES;
    }
    if (signModel.fromType == 2) {
        self.label9.hidden = NO;
        self.label10.hidden = NO;
        // 司机待确认
        if (signModel.driverComfirmStat == 1) {
    
            self.label10.textColor = mainColor;
            self.label10.backgroundColor = [mainColor colorWithAlphaComponent:0.1];
            self.label10.text = @"司机已确认";
        }
        else {
            self.label10.textColor = ColorWithEA545A;
            self.label10.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
            self.label10.text = @"司机待确认";
        }
        // 企业待确认
        if (signModel.companyComfirmStat == 1) {
            self.label9.textColor = mainColor;
            self.label9.backgroundColor = [mainColor colorWithAlphaComponent:0.1];
            self.label9.text = @"企业已确认";
        }
        else {
            self.label9.textColor = ColorWithEA545A;
            self.label9.backgroundColor = [ColorWithEA545A colorWithAlphaComponent:0.1];
            self.label9.text = @"企业待确认";
        }
        
    }
    else {
        self.label9.hidden = YES;
        self.label10.hidden = YES;
    }
   
    
    
//    [self.btn9 setBackgroundColor:mainColor];
//    [self.btn9 setTitleColor:UIColor.whiteColor forState:UIControlStateNormal];

//    NSInteger date = [NSString compareDate:signModel.sysTime withDate:signModel.endTime withFormat:@"yyyy-MM-dd"];
//    self.btn9.hidden = NO;
//
//    if (signModel.reNewFlag == 1) {
//        if(date >= 0  && signModel.signStatus != 3){
//            [self.btn9 setTitle:@"一键续约" forState:UIControlStateNormal];
//        }
//        else if(date < 0 && signModel.signStatus != 3){
//            [self.btn9 setTitle:@"到期解约" forState:UIControlStateNormal];
//            [self.btn9 setBackgroundColor:[mainColor colorWithAlphaComponent:0.1]];
//            [self.btn9 setTitleColor:mainColor forState:UIControlStateNormal];
//        }
//        else {
//            self.btn9.hidden = YES;
//        }
//    }
//    else if(signModel.reNewFlag != 1 && date > 0){
//        self.btn9.hidden = YES;
//    }
    
    
    if(signModel.signStatus == 3){
        self.label1.textColor = ColorWithAAAAAA;
        self.label2.textColor = ColorWithAAAAAA;
        self.label3.textColor = ColorWithAAAAAA;
        self.label4.textColor = ColorWithAAAAAA;
        self.label5.textColor = ColorWithAAAAAA;
        self.label6.textColor = ColorWithAAAAAA;
        [self.label8 setTitleColor:ColorWithAAAAAA forState:UIControlStateNormal];
        self.label7.textColor = ColorWithAAAAAA;
        self.fromLabl.textColor =  ColorWithAAAAAA;
        self.fromLabl.backgroundColor = [ColorWithAAAAAA colorWithAlphaComponent:0.1];
        self.label9.textColor =  ColorWithAAAAAA;
        self.label9.backgroundColor = [ColorWithAAAAAA colorWithAlphaComponent:0.1];
        self.label10.textColor =  ColorWithAAAAAA;
        self.label10.backgroundColor = [ColorWithAAAAAA colorWithAlphaComponent:0.1];
        self.label11.textColor = ColorWithAAAAAA;
    }
    

    
    
}

- (IBAction)clickChooseAction:(UIButton *)sender {
    if (self.signModel.remindPayRentStatus == 1) return;
    sender.selected = !sender.isSelected;
    self.signModel.isSel = sender.isSelected;
    
    if (sender.isSelected) {
        [sender setImage:kImg(@"设置性别已选择") forState:UIControlStateNormal];
    }
    else {
        [sender setImage:kImg(@"未选择") forState:UIControlStateNormal];
    }
    
    if (self.clickBtnAction) {
        self.clickBtnAction(sender);
    }
}

@end
